package cn.edu.zafu.bigdata.cccnnn.workthree;

class InvalidAgeException extends Exception{
    public InvalidAgeException(String message){
        super(message);
    }
}

class Checkage{
    public static void checkAge(int age) throws InvalidAgeException {
        if (age < 18){
            throw new InvalidAgeException("Age < 18 out");
        }
        else System.out.println("Age is valid");

    }

}

public class TestInvalidAgeException {
    public static void main(String[] args){
        try{
            Checkage.checkAge(16);
        }catch (InvalidAgeException e){
            System.out.println(e.getMessage());
        }
    }
}